<?php
abstract class App_Model
{    
    /*
     * data set
     */
    protected $_data;
    
    public function __construct($data = null)
    {
        if($data !== null){
            $this->setData($data);
        }
    }
    
    /*
     * Magic setters and getters 
     */
    public function __set($field, $value)
    {
        $this->_data[$field] = $value;
    }
    
    public function __get($field)
    {
        return $this->_data[$field];
    }
    
    /*
     * set data array
     */
    public function setData(array $data)
    {
        foreach($this->_data as $key => $value){
            $this->_data[$key] = $data[$key];
        }
        $this->_data = $data;
    }
    
    /*
     * get data array
     */
    public function getData()
    {
        return $this->_data;
    }
}